local skel = fk.CreateSkill {
  name = "efengqi__luanwu",
  tags = {Skill.Limited},
}

Fk:loadTranslationTable{
  ["efengqi__luanwu"] = "乱武",
  [":efengqi__luanwu"] = "限定技，轮次开始时，你可以令所有角色同时选择两项：1.于本轮获得“鸩毒”；2.翻面；3.摸两张牌。",

  ["efengqi__luanwu_poison"] = "于本轮获得“鸩毒”",
  ["efengqi__luanwu_turnover"] = "翻面",
  ["efengqi__luanwu_draw2"] = "摸两张牌",
  ["#efengqi__luanwu-choice"] = "乱武：请选择执行2项效果",
  ["@@efengqi__luanwu_zhendu-round"] = "鸩毒",

  ["$efengqi__luanwu1"] = "哼哼哼……坐山观虎斗！",
  ["$efengqi__luanwu2"] = "哭喊吧，哀求吧，挣扎吧，然后，死吧！",
}

skel:addEffect(fk.RoundStart, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and player:usedSkillTimes(skel.name, Player.HistoryGame) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = room:getAlivePlayers()
    room:doIndicate(player, targets)

    -- 应该封装一下
    local choices = {"efengqi__luanwu_poison", "efengqi__luanwu_turnover", "efengqi__luanwu_draw2"}
    local req = Request:new(targets, "AskForChoices")
    req.focus_text = skel.name
    local req_data = {
      choices, choices, {2, 2}, false, skel.name, "#efengqi__luanwu-choice", false
    }
    for _, p in ipairs(targets) do
      req:setData(p, req_data)
      req:setDefaultReply(p, table.random(choices, 2))
    end
    req:ask()
    local result = {}
    for _, p in ipairs(targets) do
      result[p] = req:getResult(p)
    end

    for _, p in ipairs(targets) do
      local ret = result[p]
      if not p.dead then
        if table.contains(ret, choices[1]) then
          room:setPlayerMark(p, "@@efengqi__luanwu_zhendu-round", 1)
          room:handleAddLoseSkills(p, "efengqi__zhendu")
          room.logic:getCurrentEvent():findParent(GameEvent.Round):addCleaner(function()
            room:handleAddLoseSkills(p, "-efengqi__zhendu")
          end)
        end
      end
      if not p.dead and table.contains(ret, choices[2]) then
        p:turnOver()
      end
      if not p.dead and table.contains(ret, choices[3]) then
        p:drawCards(2, skel.name)
      end
    end
  end,
})



return skel
